<?php
class documenttype extends Controller{

	function index(){
		if(!$this->user->isLogged()){
			$this->response->redirect(MAIN_PAGE);
		}
		$this->document->setTitle("Document Management Solutions");
		$this->document->setSelectedMenu("menu_setting");
		$this->children=array("header","footer");
		$this->template="documenttype.html";
		$this->response->setOutput($this->render(TRUE),0);
	}

	function documenttypepost(){
		$jsonarr=array();
		if($this->request->is_ajax_request() && $this->user->isLogged()){
			$this->load->model("doctype");
			if($this->model_doctype->checkdoctypecodeexist($this->db->escape($_POST["doctypecode"]))==0){
				$this->model_doctype->insertdoctype();
				$jsonarr["status"]=true;
				$jsonarr["msg"]	="Document Type saved successfully";
			}
			else{
				$jsonarr["status"]=false;
				$jsonarr["msg"]	="Department Type code already exit.Please try again.";
			}				
		}
		else{
			$jsonarr["status"]=false;
			$jsonarr["redirect"]=true;
		}
		echo json_encode($jsonarr);
	}
}
?>